var close = document.getElementById("close_img");
var ad = document.getElementById("ad");
var enter_ad = document.getElementById("enter_ad");
//关闭广告
close.onclick = function(){
    ad.style.display = "none";
}
//进入广告
enter_ad.onclick = function(){
    window.open("https://detail.1688.com/offer/668236609654.html?" +
        "spm=a312h.2018_new_sem.dh_002.3.7eac5e9cWpAP55&cosite=360jj&tracelog=p4p&" +
        "_p_isad=1&clickid=2d4eae9863e74f44ae38e81bf8fdd01a&sessionid=e09ddc3e6ec46ffa0317360649b6179c");
}


//滚动图片
window.onload = function(){
    var box=this.document.getElementsByClassName("re")[0];
    var lik=box.getElementsByTagName("li");
    function fun(i,j){//转换图片函数，就是把透明度改了一下
        lik[i].style.opacity=1;
        lik[j].style.opacity=0;
        lik[i+5].style.backgroundColor="#ffffff";//改一下小图标
        lik[j+5].style.backgroundColor="#00000000"
    }
    fun(0,1);//初始化下
    var i =0;
    function auto(){//轮播循环函数
        if(++i>=5){
            i=0;
            fun(0,4);
        }
        else fun(i,i-1);
    }
    timer=this.setInterval(auto,2000);
    box.onmouseover = function () { //鼠标划上去，停止轮播
        console.log('good');
        clearInterval(timer);
    }
    box.onmouseout = function () { //鼠标划出，继续轮播
        timer = setInterval(auto, 2000); //调用定时器
    }
    var j =0;
    for(;j<5;j++){//点击小图标也可以转换图片
        lik[j+5].ind=j;
        lik[j+5].onclick=function(){
            fun(this.ind,i)
            i=this.ind;
        }
    }
}
